﻿using Model;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using Model;



//1-1 from lsl
namespace DAL
{
    public class D_Student
    {



        //public bool Login_sugar(Student m_stu)
        //{
        //    //var student = Sugar_helper.Db.Queryable<Student>().Where(stu => stu.stu_no == m_stu.stu_no && stu.pwd == m_stu.pwd).ToList();
        //    //if (student.Count == 0)
        //    //    return false;

        //    //log_info.Server_Time = Sugar_helper.Db.GetDate();

        //    //log_info.student = student[0];

        //    //if (student[0].group_id != -1)
        //    //{
        //    //    var stu_group = Sugar_helper.Db.Queryable<Stu_group>().Where(g => g.group_id == student[0].group_id).ToList().First();
        //    //    log_info.stu_Group = stu_group;
        //    //}

        //    //var sys_config = Sugar_helper.Db.Queryable<Sys_config>().ToList();
        //    //if (sys_config.Count > 0)
        //    //    log_info.Sys_Config.group_members = sys_config[0].group_members;

        //    return true;

 

        public bool Login_sugar(Student m_stu)
        {
            var count = Sugar_helper.Db.Queryable<Student>().Where(s => s.stu_no == m_stu.stu_no && s.pwd == m_stu.pwd).Count();
            return count > 0;
            
        }

        public List<Student> GetList()
        {
            var list = Sugar_helper.Db.Queryable<Student>().Take(20).ToList();
            return list;
        }



    }
}